#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#


#
#	Scratch workspace.
#

from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext import db
from Tweet_model import GeoTweet_model
from Tweet_model import GML

import operator
import time
import datetime
import header
import footer
import urllib2
import simplejson
import re
import Stalker
from urllib2 import *
import httplib, urllib
#Thanks To Mike Dirolf
#http://dirolf.com/project/pyporter2
import Stemmer

class Dump(webapp.RequestHandler):
	@staticmethod
	def getSilent():
		def contains(list, filter):
			for x in list:
				if filter(x):
					return True
				return False	
		#self.response.out.write(header.head)
		'''self.response.out.write(
		 <div class="content">
			<div class="content_resize">
				
					<div class="article">
						<div class="clr"></div>
		'''   #)     

		'''self.response.out.write("<table width = 100%>")
		self.response.out.write("<tr><td>Special thanks to</td><td>Powered by Google</td></tr>")
		self.response.out.write("<tr><td>Special thanks to</td><td>http://www.ranks.nl</td></tr>")
		self.response.out.write("<tr><td>Special thanks to</td><td>Mike Dirolf http://dirolf.com/</td></tr>")
		self.response.out.write("</table>")'''
		
		
		
		#t_database = db.GqlQuery("SELECT * FROM GeoTweet_model \
		#ORDER BY created_at DESC LIMIT 50" )
		
		#Begin GeoLocations 
		#t_database = db.GqlQuery("SELECT * FROM GeoTweet_model \
		#WHERE geo != 'null'")
		#End GeoLocations 
		#self.response.out.write("<hr width=100%><br><b><center>Timeout on check-in data</center></b><br>")
		query = GeoTweet_model.all()
		query = db.Query(GeoTweet_model)
		
		#How old the tweets are
		delta = datetime.timedelta(hours = 5)
		query.filter('created_at >', datetime.datetime.now()-delta)
		query.order('-created_at')
	
		#Query only once, then do fancy things
		#Mental note: When deploy, put in LIMIT 20
		q_res = query.fetch(limit = 50)
		
		dictionary = {}
		s_words = {}
		stemmer = Stemmer.Stemmer('english')
		

		
		'''self.response.out.write("<table width = 100%><tr>")
		self.response.out.write("<td>Now is</td><td>")
		self.response.out.write(datetime.datetime.now())
		self.response.out.write("</td></tr><tr><td>Considering until</td><td>")
		self.response.out.write(datetime.datetime.now()-delta)
		self.response.out.write("</td></tr></table>")

		
		self.response.out.write("<hr width=100%><br><b><center>Tweets</center></b><br>")
		self.response.out.write("<table width=100% border=3>")
		self.response.out.write("<tr>")
		self.response.out.write("<td>screen_name</td>")
		self.response.out.write("<td>id_str</td>")
		self.response.out.write("<td>real_name</td>")
		self.response.out.write("<td>geo</td>")
		self.response.out.write("<td>location</td>")
		self.response.out.write("<td>created_at</td>")
		self.response.out.write("<td>text</td>")
		self.response.out.write("</tr>")'''
		
		
		
		
		#Thank you for the stopwords http://www.ranks.nl/resources/stopwords.html
		f = open("stopwords.txt", "r")
		for line in f:
			s_words[line.rstrip('\n')] = True
		#self.response.out.write(s_words)

		for _tweet in q_res:
		#for _tweet in t_database:
			'''self.response.out.write("<tr>")
			self.response.out.write("<td>"+str(_tweet.screen_name)+"</td>")
			self.response.out.write("<td>"+str(_tweet.id_str)+"</td>")
			self.response.out.write("<td>"+str(_tweet.real_name)+"</td>")
			self.response.out.write("<td>"+str(_tweet.geo)+"</td>")
			self.response.out.write("<td>"+str(_tweet.location)+"</td>")
			self.response.out.write("<td>"+str(_tweet.created_at)+"</td>")
			self.response.out.write("<td>"+str(_tweet.text)+"</td>")'''
		
			#Extract keywords
			clean_string = re.sub('[^a-z0-9]', ' ', _tweet.text.lower())
			tokens = clean_string.split()
			for _words in tokens:
				word = _words	#Stemming disabled
				#word = stemmer.stemWord(_words)	#Stemming enabled
				if (word not in dictionary) and (word not in s_words):
					dictionary[word] = 1
				else:
					if word not in s_words:
						dictionary[word] += 1
			
			#self.response.out.write("</tr>")
		#self.response.out.write("</table>")
		#Create simple occurance ranking
		#self.response.out.write("<br><br><hr width=100%><br><b><center>Word Frequency</center></b><br>")
		keyword_to_lookup = []
		sorted_dict = sorted(dictionary.iteritems(), key=operator.itemgetter(1), reverse=True)
		for a in sorted_dict:
			if ((len(a[0]) > 3) and (a[1] > 2) ):
				try:	#Test for unicode character
					if a[0].startswith('u'):
						b = '\\'+b
						if(ord(b) < 128):
							keyword_to_lookup.append(b)	#Regular ASCII in unicode
							self.response.out.write("<br>Adding tricky word:"+str(b)+" "+str(a[1])+"<br>")
					else:
							keyword_to_lookup.append(a[0])	#Regular ASCII in ASCII
							self.response.out.write("<br>Adding regular word:"+str(a[0])+" "+str(a[1])+"<br>")
				except:
					pass
			else:
				pass
				#self.response.out.write("<br>Not long enough or not frequent enough:\t\t"+str(a[0])+"\t<b>"+str(a[1])+"</b><br>")
		#self.response.out.write("Keywords are: ")
		#for a in keyword_to_lookup:
		#	self.response.out.write("&nbsp;<b>"+a+"</b>")
		
		
		
		#Google Maps Coordinates
		locationstring = "northgate+college+station,+tx"	#Later can be modified to dynamic
		latlon = ""
		lat = ""
		lng = ""
		
		url_geocode_gmaps = 'http://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false' % (locationstring)	    #google maps api to get lat,lon based on location
		f_geocode_gmaps = urlopen(url_geocode_gmaps)
		while not f_geocode_gmaps:
			f = urlopen(url_geocode_gmaps)
			print "bad"
		results = simplejson.loads(f_geocode_gmaps.read())
		#print results
		for each in results['results']:
			lat = str(each['geometry']['location']['lat'])
			lng = str(each['geometry']['location']['lng'])
			break        
		f_geocode_gmaps.close()
		#self.response.out.write("Location Coordinates for %s is %s , %s<br><br>" % (locationstring, lat, lng))
		gml_list = []
		for _keyword in keyword_to_lookup[:10]:
			#self.response.out.write("KEYWORD: "+_keyword+"<br>")
			#Google Places
			r = "5000"	#5km radius
			types = "food|bar|cafe|night_club|restaurant"
			sensor_type = "false"
			url = 'https://maps.googleapis.com/maps/api/place/search/json?\
location='+lat+','+lng\
			+'&radius='+r\
			+'&keyword='+_keyword\
			+'&types='+types\
			+'&sensor='+sensor_type\
			+'&key=AIzaSyBf51SRNjnRRneaURosVSjdFHcGB2PCRaY'
					
			try:
				result = urllib2.urlopen(url)
				data = simplejson.load(result)
			except urllib2.URLError, e:
					continue
					#print(e.code)
					#print(e.read())
					#return
			#self.response.out.write(data["status"])
			
			if data["status"] == "ZERO_RESULTS":
				
				pass
		#		self.response.out.write("<br><br><hr width=100%><br><b><center>Place Results</center></b><br>")
		#		self.response.out.write("<table width=100%>")
		#		self.response.out.write("<tr><td colspan=4>Based on tweet text for keyword <b>"+_keyword+"</b><br>Search URL: "+url+"</td>")
		#		self.response.out.write("<table><tr><td>ZERO_RESULTS</td></tr></table><br><br>")
			if data["status"] == "OVER_QUERY_LIMIT":
				pass
		#		self.response.out.write("<br>OVER_QUERY_LIMIT")
			if data["status"] == "REQUEST_DENIED":
				pass
		#		self.response.out.write("<br>REQUEST_DENIED")
			if data["status"] == "INVALID_REQUEST":
				pass
		#		self.response.out.write("<br>INVALID_REQUEST")
			if data["status"] == "OK":
				
		#			self.response.out.write("<hr width=100%><br><b><center>Place Results</center></b><br>")
					#self.response.out.write("<br><b>Number of places</b>: "+str(len(data["results"])))
				
					
				#self.response.out.write("<br><br>"+str(len(data["results"])))
					for place in data["results"]:
						
						if len(data["results"]) <= 14:
							if "icon" not in place: place["icon"] = 0
							if "id" not in place: place["id"] = 0
							if "name" not in place: place["name"] = 0
							if "rating" not in place: place["rating"] = 0
							if "reference" not in place: place["reference"] = 0
							if "vicinity" not in place: place["vicinity"] = 0
							gml = GML(
								place["geometry"]["location"]["lat"],
								place["geometry"]["location"]["lng"],
								place["icon"],
								place["id"],
								place["name"],
								place["rating"],
								place["reference"],
								place["vicinity"],
								0
								)
							for i in gml_list:
								if i.name == gml.name:
									i.hootscore += 1
									#self.response.out.write(gml.name+" HOOT! "+str(gml.hootscore))
									break
							#if (filter(lambda x: (x.name == gml.name), gml_list)):
								#gml_list
							
								
							else:
								pass
								#self.response.out.write(gml.name+" naa...<br>")
							#DDD = [x for x in gml_list if x.name == "Dixie Chicken"]
							#self.response.out.write("HOOT2!! "+str(DDD)+"<br>")
							#if contains(gml_list, lambda x: x.name == "Dixie Chicken"):
							#	gml.hootscore += 1
							#	self.response.out.write("HOOT!! "+gml.name+" "+gml.hootscore+"<br>")
							#else:
							#	self.response.out.write("Appending |"+gml.name+"|<br>")
							gml_list.append(gml)
						else:
		#					self.response.out.write("<br>Too broad definition<br>")
							break
						#self.response.out.write(len(gml_list))	
		#			self.response.out.write("<table width=100%>")
		#			self.response.out.write("<tr><td colspan=4>Based on tweet text for keyword <b>"+_keyword+"</b><br>Search URL: "+url+"</td>")
		#			self.response.out.write("</table><br><br>")
					
		
		#sorted_gml = sorted(gml_rank.iteritems(), key=operator.itemgetter(0), reverse=True)
		#self.response.out.write("<br><br><hr width=100%><hr width=100%><br><b><center>FINAL SCORES</center></b><br>")
		#self.response.out.write("<table width=100%>")
		gml_list.sort(key = operator.attrgetter('hootscore'), reverse = True)
		retval = []
		for a in gml_list:
			if a.hootscore > 0:
				a.name = a.name.replace(u"\u0027"," ")
				a.name = a.name.encode("ascii").replace("\""," ")
				a.name = a.name.encode("ascii").replace("\'"," ")
				a.name = a.name.encode("ascii").replace("\\","")
				a.name = a.name.encode("ascii").replace("'"," ")
				
				retval.append(a.name.encode("ascii"))
				retval.append(a.lat)
				retval.append(a.lng)
		return retval	
		'''self.response.out.write("<tr><td>"+str(a.name)+"</td><td>"+str(a.hootscore)+"</td><td>")
			#if a[0] in gml_rank:
			#	self.response.out.write(gml_rank[a[0]])
			#else:
			#	self.response.out.write("WTF?")
		#	self.response.out.write("&nbsp;</td></tr>")
		self.response.out.write("</table>")
			#self.response.out.write("<br><br>")
		self.response.out.write("<br><br>")
		self.response.out.write("</table>")
		self.response.out.write(retval)		
			#self.response.out.write(str(_tweet.created_at)+"<br>")
			#self.response.out.write(_tweet.geo+"|||")
			#self.response.out.write(_tweet.coordinates+"<br>")
			
			
			
		
		self.response.out.write(
        </div>
      </div>
      <div class="sidebar">
        <div class="gadget">
          
          <div class="clr"></div>
          
        </div>
        <div class="gadget">
          <div class="clr"></div>
          </ul>
        </div>
      </div>
      <div class="clr"></div>
    </div>
  </div>
  <div class="fbg">
    <div class="fbg_resize">
      <div class="col c1">
        </div>
      <div class="col c3">
        </div>
      <div class="clr"></div>
    </div>
  </div>
		'''#)		
	        #self.response.out.write(footer.foot)


		
		
		
		
		
		
		
		
		
		
		
		
		
	## ## DEBUG VERSION ## ##
	def get(self):
		def contains(list, filter):
			for x in list:
				if filter(x):
					return True
				return False	
		self.response.out.write(header.head)
		self.response.out.write('''  
		 <div class="content">
			<div class="content_resize">
				
					<div class="article">
						<div class="clr"></div>
		'''   )     

		self.response.out.write("<table width = 100%>")
		self.response.out.write("<tr><td>Special thanks to</td><td>Powered by Google</td></tr>")
		self.response.out.write("<tr><td>Special thanks to</td><td>http://www.ranks.nl</td></tr>")
		self.response.out.write("<tr><td>Special thanks to</td><td>Mike Dirolf http://dirolf.com/</td></tr>")
		self.response.out.write("</table>")
		
		
		
		#t_database = db.GqlQuery("SELECT * FROM GeoTweet_model \
		#ORDER BY created_at DESC LIMIT 50" )
		
		#Begin GeoLocations 
		#t_database = db.GqlQuery("SELECT * FROM GeoTweet_model \
		#WHERE geo != 'null'")
		#End GeoLocations 
		self.response.out.write("<hr width=100%><br><b><center>Timeout on check-in data</center></b><br>")
		query = GeoTweet_model.all()
		query = db.Query(GeoTweet_model)
		
		#How old the tweets are
		delta = datetime.timedelta(hours = 5)
		query.filter('created_at >', datetime.datetime.now()-delta)
		query.order('-created_at')
	
		#Query only once, then do fancy things
		#Mental note: When deploy, put in LIMIT 20
		q_res = query.fetch(limit = 50)
		
		dictionary = {}
		s_words = {}
		stemmer = Stemmer.Stemmer('english')
		

		
		self.response.out.write("<table width = 100%><tr>")
		self.response.out.write("<td>Now is</td><td>")
		self.response.out.write(datetime.datetime.now())
		self.response.out.write("</td></tr><tr><td>Considering until</td><td>")
		self.response.out.write(datetime.datetime.now()-delta)
		self.response.out.write("</td></tr></table>")

		
		self.response.out.write("<hr width=100%><br><b><center>Tweets</center></b><br>")
		self.response.out.write("<table width=100% border=3>")
		self.response.out.write("<tr>")
		self.response.out.write("<td>screen_name</td>")
		self.response.out.write("<td>id_str</td>")
		self.response.out.write("<td>real_name</td>")
		self.response.out.write("<td>geo</td>")
		self.response.out.write("<td>location</td>")
		self.response.out.write("<td>created_at</td>")
		self.response.out.write("<td>text</td>")
		self.response.out.write("</tr>")
		
		
		
		
		#Thank you for the stopwords http://www.ranks.nl/resources/stopwords.html
		f = open("stopwords.txt", "r")
		for line in f:
			s_words[line.rstrip('\n')] = True
		#self.response.out.write(s_words)

		for _tweet in q_res:
		#for _tweet in t_database:
			self.response.out.write("<tr>")
			self.response.out.write("<td>"+str(_tweet.screen_name)+"</td>")
			self.response.out.write("<td>"+str(_tweet.id_str)+"</td>")
			self.response.out.write("<td>"+str(_tweet.real_name)+"</td>")
			self.response.out.write("<td>"+str(_tweet.geo)+"</td>")
			self.response.out.write("<td>"+str(_tweet.location)+"</td>")
			self.response.out.write("<td>"+str(_tweet.created_at)+"</td>")
			self.response.out.write("<td>"+str(_tweet.text)+"</td>")
		
			#Extract keywords
			clean_string = re.sub('[^a-z0-9]', ' ', _tweet.text.lower())
			tokens = clean_string.split()
			for _words in tokens:
				word = _words	#Stemming disabled
				#word = stemmer.stemWord(_words)	#Stemming enabled
				if (word not in dictionary) and (word not in s_words):
					dictionary[word] = 1
				else:
					if word not in s_words:
						dictionary[word] += 1
			
			self.response.out.write("</tr>")
		self.response.out.write("</table>")
		#Create simple occurance ranking
		self.response.out.write("<br><br><hr width=100%><br><b><center>Word Frequency</center></b><br>")
		keyword_to_lookup = []
		sorted_dict = sorted(dictionary.iteritems(), key=operator.itemgetter(1), reverse=True)
		for a in sorted_dict:
			if ((len(a[0]) > 3) and (a[1] > 2) ):
				try:	#Test for unicode character
					if a[0].startswith('u'):
						b = '\\'+b
						if(ord(b) < 128):
							keyword_to_lookup.append(b)	#Regular ASCII in unicode
							self.response.out.write("<br>Adding tricky word:"+str(b)+" "+str(a[1])+"<br>")
					else:
							keyword_to_lookup.append(a[0])	#Regular ASCII in ASCII
							self.response.out.write("<br>Adding regular word:"+str(a[0])+" "+str(a[1])+"<br>")
				except:
					pass
			else:
				pass
				self.response.out.write("<br>Not long enough or not frequent enough:\t\t"+str(a[0])+"\t<b>"+str(a[1])+"</b><br>")
		self.response.out.write("Keywords are: ")
		for a in keyword_to_lookup:
			self.response.out.write("&nbsp;<b>"+a+"</b>")
		
		
		
		#Google Maps Coordinates
		locationstring = "northgate+college+station,+tx"	#Later can be modified to dynamic
		latlon = ""
		lat = ""
		lng = ""
		
		url_geocode_gmaps = 'http://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false' % (locationstring)	    #google maps api to get lat,lon based on location
		f_geocode_gmaps = urlopen(url_geocode_gmaps)
		while not f_geocode_gmaps:
			f = urlopen(url_geocode_gmaps)
			print "bad"
		results = simplejson.loads(f_geocode_gmaps.read())
		#print results
		for each in results['results']:
			lat = str(each['geometry']['location']['lat'])
			lng = str(each['geometry']['location']['lng'])
			break        
		f_geocode_gmaps.close()
		#self.response.out.write("Location Coordinates for %s is %s , %s<br><br>" % (locationstring, lat, lng))
		gml_list = []
		for _keyword in keyword_to_lookup[:10]:
			#self.response.out.write("KEYWORD: "+_keyword+"<br>")
			#Google Places
			r = "5000"	#5km radius
			types = "food|bar|cafe|night_club|restaurant"
			sensor_type = "false"
			url = 'https://maps.googleapis.com/maps/api/place/search/json?\
location='+lat+','+lng\
			+'&radius='+r\
			+'&keyword='+_keyword\
			+'&types='+types\
			+'&sensor='+sensor_type\
			+'&key=AIzaSyBf51SRNjnRRneaURosVSjdFHcGB2PCRaY'
					
			try:
				result = urllib2.urlopen(url)
				data = simplejson.load(result)
			except urllib2.URLError, e:
					continue
					#print(e.code)
					#print(e.read())
					#return
			#self.response.out.write(data["status"])
			
			if data["status"] == "ZERO_RESULTS":
				self.response.out.write("<br><br><hr width=100%><br><b><center>Place Results</center></b><br>")
				self.response.out.write("<table width=100%>")
				self.response.out.write("<tr><td colspan=4>Based on tweet text for keyword <b>"+_keyword+"</b><br>Search URL: "+url+"</td>")
				self.response.out.write("<table><tr><td>ZERO_RESULTS</td></tr></table><br><br>")
			if data["status"] == "OVER_QUERY_LIMIT":
				self.response.out.write("<br>OVER_QUERY_LIMIT")
			if data["status"] == "REQUEST_DENIED":
				self.response.out.write("<br>REQUEST_DENIED")
			if data["status"] == "INVALID_REQUEST":
				self.response.out.write("<br>INVALID_REQUEST")
			if data["status"] == "OK":
					self.response.out.write("<hr width=100%><br><b><center>Place Results</center></b><br>")
					#self.response.out.write("<br><b>Number of places</b>: "+str(len(data["results"])))
				
					
				#self.response.out.write("<br><br>"+str(len(data["results"])))
					for place in data["results"]:
						
						if len(data["results"]) <= 14:
							if "icon" not in place: place["icon"] = 0
							if "id" not in place: place["id"] = 0
							if "name" not in place: place["name"] = 0
							if "rating" not in place: place["rating"] = 0
							if "reference" not in place: place["reference"] = 0
							if "vicinity" not in place: place["vicinity"] = 0
							gml = GML(
								place["geometry"]["location"]["lat"],
								place["geometry"]["location"]["lng"],
								place["icon"],
								place["id"],
								place["name"],
								place["rating"],
								place["reference"],
								place["vicinity"],
								0
								)
							for i in gml_list:
								if i.name == gml.name:
									i.hootscore += 1
									self.response.out.write(gml.name+" HOOT! "+str(gml.hootscore))
									break
							#if (filter(lambda x: (x.name == gml.name), gml_list)):
								#gml_list
							
								
							else:
								self.response.out.write(gml.name+" Inserted into watchlist, but not hot enough yet...<br>")
							#DDD = [x for x in gml_list if x.name == "Dixie Chicken"]
							#self.response.out.write("HOOT2!! "+str(DDD)+"<br>")
							#if contains(gml_list, lambda x: x.name == "Dixie Chicken"):
							#	gml.hootscore += 1
							#	self.response.out.write("HOOT!! "+gml.name+" "+gml.hootscore+"<br>")
							#else:
							#	self.response.out.write("Appending |"+gml.name+"|<br>")
							gml_list.append(gml)
						else:
							self.response.out.write("<br>Too broad definition<br>")
							break
						#self.response.out.write(len(gml_list))	
					self.response.out.write("<table width=100%>")
					self.response.out.write("<tr><td colspan=4>Based on tweet text for keyword <b>"+_keyword+"</b><br>Search URL: "+url+"</td>")
					self.response.out.write("</table><br><br>")
					
		
		#sorted_gml = sorted(gml_rank.iteritems(), key=operator.itemgetter(0), reverse=True)
		self.response.out.write("<br><br><hr width=100%><hr width=100%><br><b><center>FINAL SCORES</center></b><br>")
		self.response.out.write("<table width=100%>")
		gml_list.sort(key = operator.attrgetter('hootscore'), reverse = True)
		retval = []
		for a in gml_list:
			if a.hootscore > 0:
				a.name = a.name.replace(u"\u0027"," ")
				a.name = a.name.encode("ascii").replace("\""," ")
				a.name = a.name.encode("ascii").replace("\'"," ")
				a.name = a.name.encode("ascii").replace("\\"," ")
				a.name = a.name.encode("ascii").replace("'"," ")
				
				retval.append(a.name.encode("ascii"))
				retval.append(a.lat)
				retval.append(a.lng)
				self.response.out.write("<tr><td>"+str(a.name)+"</td><td>"+str(a.hootscore)+"</td><td>")
			#if a[0] in gml_rank:
			#	self.response.out.write(gml_rank[a[0]])
			#else:
			#	self.response.out.write("WTF?")
			self.response.out.write("&nbsp;</td></tr>")
		self.response.out.write("</table>")
			#self.response.out.write("<br><br>")
		self.response.out.write("<br><br>")
		self.response.out.write("</table>")
		self.response.out.write(retval)		
			#self.response.out.write(str(_tweet.created_at)+"<br>")
			#self.response.out.write(_tweet.geo+"|||")
			#self.response.out.write(_tweet.coordinates+"<br>")
			
			
			
		
		self.response.out.write('''
        </div>
      </div>
      <div class="sidebar">
        <div class="gadget">
          
          <div class="clr"></div>
          
        </div>
        <div class="gadget">
          <div class="clr"></div>
          </ul>
        </div>
      </div>
      <div class="clr"></div>
    </div>
  </div>
  <div class="fbg">
    <div class="fbg_resize">
      <div class="col c1">
        </div>
      <div class="col c3">
        </div>
      <div class="clr"></div>
    </div>
  </div>
		''')		
	        self.response.out.write(footer.foot)

if __name__ == '__main__':
    main()